home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / AvantBrowser / asetup.exe / _data / webkit / chrome_100_percent.pak / Unnamed File 000049.txt < prev    next >
Text File  |  2013-04-03  |  2KB  |  48 lines

  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4.  
  5. // Custom bindings for the types API.
  6.  
  7. var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
  8. var sendRequest = require('sendRequest').sendRequest;
  9. var validate = require('schemaUtils').validate;
  10.  
  11. chromeHidden.registerCustomType('types.ChromeSetting', function() {
  12.  
  13.   function extendSchema(schema) {
  14.     var extendedSchema = schema.slice();
  15.     extendedSchema.unshift({'type': 'string'});
  16.     return extendedSchema;
  17.   }
  18.  
  19.   function ChromeSetting(prefKey, valueSchema) {
  20.     this.get = function(details, callback) {
  21.       var getSchema = this.functionSchemas.get.definition.parameters;
  22.       validate([details, callback], getSchema);
  23.       return sendRequest('types.ChromeSetting.get',
  24.                          [prefKey, details, callback],
  25.                          extendSchema(getSchema));
  26.     };
  27.     this.set = function(details, callback) {
  28.       var setSchema = this.functionSchemas.set.definition.parameters.slice();
  29.       setSchema[0].properties.value = valueSchema;
  30.       validate([details, callback], setSchema);
  31.       return sendRequest('types.ChromeSetting.set',
  32.                          [prefKey, details, callback],
  33.                          extendSchema(setSchema));
  34.     };
  35.     this.clear = function(details, callback) {
  36.       var clearSchema = this.functionSchemas.clear.definition.parameters;
  37.       validate([details, callback], clearSchema);
  38.       return sendRequest('types.ChromeSetting.clear',
  39.                          [prefKey, details, callback],
  40.                          extendSchema(clearSchema));
  41.     };
  42.     this.onChange = new chrome.Event('types.ChromeSetting.' + prefKey +
  43.                                      '.onChange');
  44.   };
  45.  
  46.   return ChromeSetting;
  47. });
  48.